import java.math.BigDecimal;
import java.util.logging.Logger;

public class CreditCard extends CashCard
{
  public CreditCard(String cardNo, String cardDate) 
  {
    super(cardNo, cardDate);
  }
  boolean rule2(BigDecimal amount) 
  {
    return(amount.compareTo(new BigDecimal(1000)) <= 0);
  }
  Logger logger = Logger.getLogger(CreditCard.class.getName());
  /**
   * 提现，信用卡贷款
   *
   * @param orderId 单号
   * @param amount  金额
   * @return 状态码
   */
  public String loan(String orderId, BigDecimal amount) 
  {
    boolean rule = this.rule2(amount);
    if (!rule) 
    {
      this.logger.info("生成贷款单失败，金额超限。单号：" + orderId + " 金额：" + amount);
      return "0001";
    }
    // 模拟生成贷款单
    this.logger.info("生成贷款单，单号：" + orderId + " 金额：" + amount);
    // 模拟支付成功
    this.logger.info("贷款成功，单号：" + orderId + " 金额：" + amount);
    return(super.negative(orderId, amount));
  }

  /**
   * 还款，信用卡还款
   *
   * @param orderId 单号
   * @param amount  金额
   * @return 状态码
   */
  public String repayment(String orderId, BigDecimal amount) 
  {
    // 模拟生成还款单
    this.logger.info("生成还款单，单号：" + orderId + "金额：" + amount);
    // 模拟还款成功
    this.logger.info("还款成功，单号：" + orderId + " 金额：" + amount);
    return(super.positive(orderId, amount));
  }
}
